package com.wtwd.device.controller;


import com.wtwd.device.model.entity.DeviceSetting;
import com.wtwd.device.model.entity.DialManagement;
import com.wtwd.device.model.entity.DialPlate;
import com.wtwd.device.model.vo.RespEntity;
import com.wtwd.device.model.vo.ResultVO;
import com.wtwd.device.service.AppDialService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author mjy
 * @date 2021/08/11
 * @description
 */
@Api(tags = "表盘管理")
@RestController
@RequestMapping("/app-dial")
public class AppDialController {

    private static final Logger logger = LoggerFactory.getLogger(AppDialController.class);

    @Autowired
    private AppDialService dialService;

    /**
     * 分页获取默认表盘
     *
     * @param watchId
     * @return
     */
    @ApiOperation(value = "分页获取默认表盘", notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage", value = "当前页", required = true, dataTypeClass = Integer.class, example = "起始页0")
            , @ApiImplicitParam(name = "pageSize", value = "页面大小", required = true, dataTypeClass = Integer.class)
            , @ApiImplicitParam(name = "watchId", value = "手表id", required = true, dataTypeClass = String.class)
    })
    @GetMapping("/getDefaultDialList")
    public RespEntity<DialPlate> getDefaultDialList(@RequestParam("currentPage") Integer currentPage
            , @RequestParam("pageSize") Integer pageSize
            , @RequestParam("watchId") String watchId) {
        logger.info("getDefaultDialList param" + currentPage, pageSize, watchId);
        return dialService.getDefaultDialList(currentPage, pageSize, watchId);
    }


    /**
     * 获取当前默认表盘详细信息
     *
     * @param dialId
     * @return
     */
    @ApiOperation(value = "获取当前默认表盘详细信息", notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "dialId", value = "表盘id", required = true, dataTypeClass = Integer.class)
    })
    @GetMapping("/getDefaultDialInfo/{dialId}")
    public RespEntity<DialPlate> getDefaultDialInfo(@PathVariable("dialId") Integer dialId) {
        logger.info("getDefaultDialInfo param" + dialId);
        return dialService.getDefaultDialInfo(dialId);
    }

    /**
     * 获取表盘管理列表
     *
     * @param currentPage
     * @param pageSize
     * @param watchId
     * @return
     */
    @ApiOperation(value = "获取表盘管理列表", notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "currentPage", value = "当前页", required = true, dataTypeClass = Integer.class, example = "起始页0")
            , @ApiImplicitParam(name = "pageSize", value = "页面大小", required = true, dataTypeClass = Integer.class)
            , @ApiImplicitParam(name = "watchId", value = "手表id", required = true, dataTypeClass = String.class)
    })
    @GetMapping("/getDialList")
    public ResultVO<List<DialManagement>> getDialList(@RequestParam("currentPage") Integer currentPage, @RequestParam("pageSize") Integer pageSize, @RequestParam("watchId") String watchId) {
        logger.info("getDialList param" + currentPage, pageSize, watchId);
        return dialService.getDialListByWatchId(currentPage, pageSize, watchId);
    }

    /**
     * 根据手表id获取产品缩略图
     *
     * @param watchId
     * @return
     */
    @ApiOperation(value = "根据手表id获取产品缩略图等信息", notes = "")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "watchId", value = "手表id", required = true, dataTypeClass = String.class)
    })
    @GetMapping("/getDeviceSetting/{watchId}")
    public RespEntity<DeviceSetting> getDeviceSetting(@PathVariable String watchId) {
        logger.info("getDeviceSetting param" + watchId);
        return dialService.getDeviceSetting(watchId);
    }


}
